﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.BLL;
using KPIS.GERP.GIMS.IBLL;
using KPIS.GERP.GIMS.MODEL;
using System.Data;
using System.IO;

namespace KPIS.GERP.GIMS.APP.APP_UI.UserControl
{
    public partial class TIP_Purchase_Order_Committee_History : System.Web.UI.UserControl
    {
        public CallBackHandleReturnInt GetBdSeq;
        IBLLPrePurchaseRequestCommittee bllPprCom = new PrePurchaseRequestCommitteeBLL();
        PurchaseRequestCommitteeBLL bllPrCommittee = new PurchaseRequestCommitteeBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                LoadGridPprCommittee();
                LoadGridPrCommittee();
            }
        }

        protected void LoadGridPprCommittee()
        {
            RadGrid TmpGrid = (RadGrid)RadPanelBar.FindItemByValue("BarH1").FindControl("Grid_Ppr_Committee");
            int seq = GetBdSeq();
            TmpGrid.DataSource = bllPprCom.GetPurchaseOrderCommitteeHistory(seq);
            GridGroupByExpression geFunction = new GridGroupByExpression(TmpGrid.Columns[0]);
            GridGroupByExpression geRefNo = new GridGroupByExpression(TmpGrid.Columns[1]);
            GridGroupByExpression geType = new GridGroupByExpression(TmpGrid.Columns[2]);
            TmpGrid.MasterTableView.GroupByExpressions.Add(geFunction);
            TmpGrid.MasterTableView.GroupByExpressions.Add(geRefNo);
            TmpGrid.MasterTableView.GroupByExpressions.Add(geType);
            TmpGrid.DataBind();
        }

        protected void Grid_Ppr_Committee_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridPprCommittee();
        }

        protected void LoadGridPrCommittee()
        {
            RadGrid TmpGrid = (RadGrid)RadPanelBar.FindItemByValue("BarH2").FindControl("Grid_Pr_Committee");
            int seq = GetBdSeq();
            TmpGrid.DataSource = bllPrCommittee.GetPurchaseOrderCommitteeHistory(seq);

            GridGroupByExpression geFunction = new GridGroupByExpression(TmpGrid.Columns[0]);
            GridGroupByExpression geRefNo = new GridGroupByExpression(TmpGrid.Columns[1]);
            GridGroupByExpression geType = new GridGroupByExpression(TmpGrid.Columns[2]);
            TmpGrid.MasterTableView.GroupByExpressions.Add(geFunction);
            TmpGrid.MasterTableView.GroupByExpressions.Add(geRefNo);
            TmpGrid.MasterTableView.GroupByExpressions.Add(geType);
            TmpGrid.DataBind();
        }

        protected void Grid_Pr_Committee_ItemCommand(object source, GridCommandEventArgs e)
        {
            LoadGridPrCommittee();
        }
    }
}